package com.longjianghuasheng.logistics.business.detail

import android.os.Bundle
import com.longjianghuasheng.logistics.R
import com.longjianghuasheng.logistics.base.BaseTitleFragment
import com.longjianghuasheng.logistics.databinding.FragmentStorageAndDisplayBinding
import com.longjianghuasheng.logistics.ext.loadUrl
import com.longjianghuasheng.logistics.ext.observer
import me.hgj.jetpackmvvm.ext.view.visible

class StorageAndDisplayFragment :
    BaseTitleFragment<StorageAndDisplayViewModel, FragmentStorageAndDisplayBinding>() {

    override fun layoutId(): Int = R.layout.fragment_storage_and_display

    override fun initView(savedInstanceState: Bundle?) {
        super.initView(savedInstanceState)
        initTitleBar("仓储展示")
        mDatabind.btnConfirm.setOnClickListener {

            navigate(R.id.warehousingFragment, Bundle().apply {
                putInt("id", mViewModel.id)
            })
        }
    }

    override fun createObserver() {
        super.createObserver()
        mViewModel.result.observer(this) {

            mDatabind.ivPic.loadUrl(it.pic)
            mDatabind.llContainer.visible()

        }
    }


    override fun initData() {
        super.initData()
        mViewModel.id = arguments?.getInt("id") ?: 0
    }


    override fun lazyLoadData() {
        super.lazyLoadData()
        mViewModel.storage_pic()
    }
}